import { ResPage, System } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 系统管理模块
 */

/**
 * @name 用户管理模块
 */

// 添加用户
export const addUser = (params: System.ResUserList) => {
  return http.post(PORT1 + `/user/addUser`, params);
};
// 删除用户
export const delUser = (params: { id: number }) => {
  return http.get(PORT1 + `/user/delUser`, params);
};
// 编辑用户
export const updateUser = (params: Partial<System.ResUserList>) => {
  return http.post(PORT1 + `/user/updateUser`, params);
};
// 用户列表
export const getUserList = (params: any) => {
  return http.get(PORT1 + `/user/getUserList`, params);
};
// 用户列表
export const changeUserStatus = (params: any) => {
  return http.post(PORT1 + `/user/changeUserStatus`, params);
};
// 重置用户密码
export const resetUserPwd = (params: any) => {
  return http.post(PORT1 + `/user/resetUserPwd`, params);
};
// 获取用户菜单路由
export const getUserRouterList = () => {
  return http.get(PORT1 + `/user/getUserRouterList`);
};

// 修改密码
export const updateUserPwd = (params: any) => {
  return http.post(`${PORT1}/user/updateUserPwd`, params);
};
/**
 * @name 角色管理模块
 */

// 添加角色
export const addRole = (params: System.ResRoleList) => {
  return http.post(PORT1 + `/role/addRole`, params);
};
// 删除角色
export const delRole = (params: { id: number }) => {
  return http.get(PORT1 + `/role/delRole`, params);
};
// 修改角色
export const updateRole = (params: System.ResRoleList) => {
  return http.post(PORT1 + `/role/updateRole`, params);
};
// 角色列表
export const getRoleList = (params: any) => {
  return http.get<ResPage<System.ResRoleList>>(PORT1 + `/role/getRoleList`, params);
};
// 通过id获取角色信息
export const getRoleById = (params: any) => {
  return http.get(PORT1 + `/role/getRoleById`, params);
};

/**
 * @name 岗位管理模块
 */

// 添加/编辑岗位
export const addOrUpdateSysPost = (params: System.ResPostList) => {
  return http.post(PORT1 + `/post/addOrUpdateSysPost`, params);
};
// 删除岗位
export const delSysPost = (params: { idList: number[] }) => {
  return http.post(PORT1 + `/post/delSysPost`, params);
};
// 岗位列表
export const getSysPostList = (params: any) => {
  return http.get<ResPage<System.ResPostList>>(PORT1 + `/post/getSysPostList`, params);
};

// 获取字典列表
export const getDictList = (params: { dictType: string }) => {
  return http.get(PORT1 + `/dictType/getDictDataList`, params);
};
// 新增/编辑字典
export const addOrUpdateDict = (params: {
  dictLabel: string;
  dictType: string;
  dictValue: string;
  id?: number;
  sort?: number;
}) => {
  return http.post(PORT1 + `/dictType/addOrUpdateDictData`, params);
};
// 删除字典
export const delDictData = (params: { idList: number[] }) => {
  return http.post(PORT1 + `/dictType/delDictData`, params);
};
// 新增/编辑字典类型
export const addOrUpdateDictType = (params: { dictName: string; dictType: string; id?: number }) => {
  return http.post(PORT1 + `/dictType/addOrUpdateDictType`, params);
};
// 获取字典类型列表
export const getDictTypeList = (params: { name?: string; page?: number; pageSize?: number }) => {
  return http.get(PORT1 + `/dictType/getDictTypeList`, params);
};
// 删除字典类型
export const delDictType = (params: { idList: number[]; paramList: string[] }) => {
  return http.post(PORT1 + `/dictType/delDictType`, params);
};

/**
 * @name 菜单管理模块
 */

// 添加菜单
export const addRouter = (params: System.ResMenuList) => {
  return http.post(PORT1 + `/router/addRouter`, params);
};
export const delRouter = (params: { id: number }) => {
  return http.get(PORT1 + `/router/delRouter`, params);
};
export const updateRouter = (params: System.ResMenuList) => {
  return http.post(PORT1 + `/router/updateRouter`, params);
};
export const getRouterList = (params: any) => {
  return http.get(PORT1 + `/router/getRouterList`, params);
};

/**
 * @name 科室管理模块
 */

// 科室事务 新增/删除
export const addOrUpdateDepartmentInfo = (params: System.ResMenuList) => {
  return http.post(PORT1 + `/departmentInfo/addOrUpdateDepartmentInfo`, params);
};
// 科室事务详情
export const formDepartmentInfo = (params: { id: number }) => {
  return http.get(PORT1 + `/departmentInfo/formDepartmentInfo`, params);
};
// 科室事务删除
export const delDepartmentInfo = (params: System.ResMenuList) => {
  return http.post(PORT1 + `/departmentInfo/delDepartmentInfo`, params);
};
// 科室事务列表
export const getDepartmentInfoList = (params: any) => {
  return http.get(PORT1 + `/departmentInfo/getDepartmentInfoList`, params);
};
